
<? include_once("../../consoles/config.php");?>
<?

//用file get content 带参数传送过来这个函数。这个函数自动拼合内容发送信息。
//公众号信息

function send_mode_message($token,$mod){

    //将上面的数组数据转为json格式
    $data = json_encode($mod);
	$access_token = $token;


	$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$access_token;


	echo "<br/>";
	echo "启动发送信息模板的url:<br/>".$url;
	echo "<br/>";
    echo "<br/>";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$data);

    $result = curl_exec($ch);
    curl_close($ch);
    return $result;

}

include_once("get_mp_access_token.php");


echo "access";

$post_data    = $_REQUEST['content'];
$post_content = unserialize($post_data);

echo $access_token;


echo "<br/><br/>";
echo "模板内容<br/>";
print_r2($post_content);
echo "<br/>";
echo "<br/>";
echo send_mode_message($access_token,$post_content);

?> 


 